transpose and flatten hacker rank solution